﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;

using ProjectBase.Core;

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace $safeprojectname$.Core.Extensions
{

    [TestClass]
    public class FormatWithTest : TestBase
    {
        [TestMethod]
        public void TwoParams_Passed()
        {
            string value = "{0}{1}";
            var result = value.FormatWith("a", "b");
            Assert.IsTrue(result.IsEqual("ab"));
        }

        [TestMethod]
        public void MoreParams_Passed()
        {
            string value = "{0}{1}";
            var result = value.FormatWith("a", "b", "c");
            Assert.IsTrue(result.IsEqual("ab"));
        }
        [TestMethod]
        public void LessParams_Failed()
        {
            Exception exception = null;
            try
            {
                string value = "{0}{1}";
                var result = value.FormatWith("a");
            }
            catch (FormatException ex)
            {
                exception = ex;
            }
            Assert.IsTrue(exception.Is());
        }

        [TestMethod]
        public void EmptyTemplate_Empty()
        {
            string value = null;
            var result = value.FormatWith("a", "b", "c");
            Assert.IsTrue(result.IsEqual(string.Empty));
        }

        #region Init

        // You can use the following additional attributes as you write your tests:

        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }

        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }

        [TestInitialize]
        public override void MyTestInitialize()
        {
            base.MyTestInitialize(); // Use TestInitialize to run code before running each test
        }

        [TestCleanup]
        public override void MyTestCleanup()
        {
            base.MyTestCleanup(); // Use TestCleanup to run code after each test has run
        }
        #endregion Init
    }
}
